package com.cleaningcloud.cld.controller;

import java.util.List;

import com.cleaningcloud.cld.domain.vo.CldProjectMaterialVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldProjectMaterial;
import com.cleaningcloud.cld.service.ICldProjectMaterialService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;

/**
 * 项目物资阈值设置Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-15
 */
@RestController
@RequestMapping("/material")
public class CldProjectMaterialController extends BaseController
{
    @Autowired
    private ICldProjectMaterialService cldProjectMaterialService;

    /**
     * 查询项目物资阈值设置列表
     */
    @GetMapping("/list/{projectId}")
    public AjaxResult list(@PathVariable Long projectId)
    {
        CldProjectMaterial cldProjectMaterial = new CldProjectMaterial();
        cldProjectMaterial.setProjectId(projectId);
        List<CldProjectMaterial> list = cldProjectMaterialService.selectCldProjectMaterialList(cldProjectMaterial);
        return success(list);
    }



    /**
     * 获取项目物资阈值设置详细信息
     */
    @GetMapping(value = "/{projectMaterialId}")
    public AjaxResult getInfo(@PathVariable("projectMaterialId") Long projectMaterialId)
    {
        return success(cldProjectMaterialService.selectCldProjectMaterialByProjectMaterialId(projectMaterialId));
    }

    /**
     * 新增项目物资阈值设置
     */
    @Log(title = "项目物资阈值设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldProjectMaterialVo projectMaterialVo)
    {
        return toAjax(cldProjectMaterialService.insertCldProjectMaterial(projectMaterialVo));
    }



}
